﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;

namespace Marmat.Forms.Skin
{
    public partial class ButtonGroupItem
    {
        public ButtonGroupItem() { }
        /// <summary>
        /// 按钮名称
        /// </summary>
        [DefaultValue(null)]
        [Category("样式"), Description("控件的名称")]
        public string Name { get; set; }
        /// <summary>
        /// 按钮图标
        /// </summary>
        [DefaultValue(null)]
        [Category("外观"), Description("控件的名称")]
        public Image Image { get; set; }

        /// <summary>
        /// 图标在右边显示
        /// </summary>
        [Category("外观"), Description("图标在右边显示,此属性只有在同时显示Text与Icon时有效")]
        [DefaultValue(typeof(TextImageRelation), nameof(TextImageRelation.TextBeforeImage))]
        public TextImageRelation TextImageRelation { get; set; } = TextImageRelation.TextBeforeImage;

        /// <summary>
        /// 获取或设置按钮宽度
        /// </summary>
        [DefaultValue(75)]
        [Category("样式"), Description("获取或设置按钮宽度")]
        public int Width { get; set; } = 75;
        /// <summary>
        /// 获取或设置按钮文本
        /// </summary>
        [DefaultValue(null)]
        [Category("外观"), Description("获取或设置按钮文本")]
        public string Text { get; set; }


        /// <summary>
        /// 获取或设置控件的背景色
        /// </summary>
        [DefaultValue(typeof(DefaultTheme), nameof(DefaultTheme.Primary))]
        [Category("外观"), Description("获取或设置控件的背景色")]
        public Color BackColor
        {
            get
            {
                Color result = this._backColor;
                if (result == default)
                {
                    switch (this.ThemeStyle)
                    {
                        case ThemeStyleEnum.Default:
                            result = Color.White;
                            break;
                        case ThemeStyleEnum.Primary:
                            result = Configuration.DefaultTheme.Primary;
                            break;
                        case ThemeStyleEnum.Success:
                            result = Configuration.DefaultTheme.Success;
                            break;
                        case ThemeStyleEnum.Info:
                            result = Configuration.DefaultTheme.Info;
                            break;
                        case ThemeStyleEnum.Warning:
                            result = Configuration.DefaultTheme.Warning;
                            break;
                        case ThemeStyleEnum.Danger:
                            result = Configuration.DefaultTheme.Danger;
                            break;
                    }
                }
                return result;
            }
            set => this._backColor = value;
        }
        private Color _backColor;

        /// <summary>
        /// 获取或设置包含有关控件的数据的对象。
        /// </summary>
        [DefaultValue(null)]
        [Category("数据"), Description("获取或设置包含有关控件的数据的对象")]
        public object Tag { get; set; }

        /// <summary>
        /// 获取或设置一个值，该值指示控件是否可以对用户交互作出响应。
        /// </summary>
        [Category("样式"), Description("获取或设置一个值，该值指示控件是否可以对用户交互作出响应。")]
        [Localizable(true)]
        [DefaultValue(true)]
        public bool Enabled { get; set; } = true;

        /// <summary>
        /// 获取或设置组件的主题样式。
        /// </summary>
        [Category("样式"), Description("获取或设置组件的主题样式。")]
        [DefaultValue(typeof(ThemeStyleEnum), nameof(ThemeStyleEnum.Primary))]
        public ThemeStyleEnum ThemeStyle
        {
            get => _themeStyle;
            set
            {
                if (this._themeStyle != value)
                {
                    this._themeStyle = value;
                }
            }
        }
        private ThemeStyleEnum _themeStyle = ThemeStyleEnum.Primary;

    }
}
